<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="wrapper">
    <div class="main clearfix">
        <div class="col_730">        
            <table width="100%" cellspacing="0" cellpadding="0" border="0" class="total_res">
                <thead>
                    <tr>
                        <th>Class ID</th>
                        <th>Code</th>
                        <th>Name</th>  
                        <th>Students</th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <% int i = 0;%>
                    <c:forEach var="classes" items="${dataClases}">
                        <tr>
                            <% i = i+1;%>
                            <td>
                                <%=i%>
                            </td>
                            <td>
                                ${classes.code}
                            <td>
                                ${classes.name}
                            </td>
                            <td>
                                <c:choose>
                                    <c:when test="${classes.students != null}">
                                        <ul>
                                            <c:forEach var="student" items="${classes.students}">
                                                <li>${student.name} - ${student.code}</li>
                                            </c:forEach>
                                        </ul>
                                    </c:when>
                                    <c:otherwise>
                                        <tr>
                                            <td colspan="6">There are no results</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td>
                                <a href="${baseUrl}/cp/classdetail/${classes.class_id}.html"><img src="<c:url value="${assetsUrl}/images/pencil.png"/>" title="Edit" alt="Edit" /></a>                               
                            </td>
                            <td>
                                <a href="${baseUrl}/cp/removeclass/${classes.class_id}.html"><img src="<c:url value="${assetsUrl}/images/trash_can.png"/>" title="Remove" alt="Remove" /></a>                               
                            </td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
             <div class="col_730" style="margin-top: 15px;">
             <c:if test="${pageCount >= 2}">
                <span class="paging">Page : </span>
                <ul class="paging">
                    <c:forEach var="i" begin="0" end="${pageCount-1}">
                        <c:choose>
                            <c:when test="${pageIndex eq i}">
                                <li class="current"><c:out value="${i}"/></li>
                            </c:when>
                            <c:otherwise>
                                    <li><a class="active" href="${baseUrl}/cp/testing.html?page=<c:out value="${i}"/>"><c:out value="${i}"/></a></li>
                            </c:otherwise>
                        </c:choose>
                    </c:forEach>
                </ul>
            </c:if>
            </div>
        </div>
         
        <div class="col_200">
            <a href="${baseUrl}/cp/addnewclass.html"> <img title="Add a new class" alt="Add a new class" src="<c:url value="/assets/images/add.png"/>" /> </a>
        </div>
    </div>
</div>
<script type="text/javascript">
    var sz_Response = "${sz_Response}";
    if (sz_Response !== "")
    {
        alert(sz_Response);
    }
</script>